package week07.personcmp;

public abstract class AbstractPersonCmp {
    protected abstract int compare(Person a,Person b);
    //sort是模板方法
    protected void sort(Person[] personArray){
        for(int i = 0;i<personArray.length;i++){
                for(int j = i+1;j<personArray.length;j++){

                    if(compare(personArray[i],personArray[j])<0){
                            Person tmp = personArray[i];
                            personArray[i] = personArray[j];
                            personArray[j] = tmp;
                    }

                }
        }
    }
}
